<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="referrer" content="no-referrer" />
    <title>开发技术</title>
  </head>

  <body>
    <div id="mainPanel" class="mainPanel"></div>

    <script type="text/javascript">
      var panelDataArr = [
        //**********
        //**********
        {
          "#title": "搜索引擎",
          bing: "https://cn.bing.com/",
        },
        {
          "#title": "开源库介绍",
          vue开源项目库: {
            url: "https://github.com/opendigg/awesome-github-vue",
            hint: "由OpenDigg整理并维护的Vue相关开源项目库集合,最后更新：2017",
          },
        },

        {
          "#title": "pc商城项目",
          Vuestorefront: {
            url: "https://vuestorefront.io/",
            hint: "面向电子商务的渐进式Web应用程序",
          },
        },
        {
          "#title": "拖拉编辑页面",
          Vuegg: {
            url: "https://github.com/opendigg/awesome-github-vue",
            hint: "Vuegg 允许您将组件直接拖放到可视化编辑器中，并根据你的选择移动它们的大小，从而构建Vue. js 项目",
          },
        },
      ];

      window.onload = function () {
        refresh("mainPanel", panelDataArr);
      };
    </script>

    <script type="text/javascript">
      function refresh(elId, panelDatas) {
        //*************************
        console.log(panelDatas);
        var mainPanel = document.getElementById(elId);
        for (var idx in panelDatas) {
          var panelData = panelDatas[idx];
          var panDom = parseDom("<div class='itemPanel'></div>");
          for (var name in panelData) {
            if (name == "#title") {
              panDom.appendChild(
                parseDom("<p class='panTitle'>" + panelData[name] + "</p>")
              );
            } else if (name == "#sub" || name.indexOf("#sub-") >= 0) {
              panDom.appendChild(
                parseDom("<p class='subTitle'>--- " + panelData[name] + "</p>")
              );
            } else {
              const info =
                typeof panelData[name] == "string"
                  ? {
                      url: panelData[name],
                    }
                  : panelData[name];
              panDom.appendChild(
                parseDom(
                  `<a href= '${info.url}' title='${
                    info.hint || ""
                  }'  target='_blank' class='link'>${name}</a>`
                )
              );
            }
          }
          mainPanel.appendChild(panDom);
        }
      }

      function parseDom(htmlText) {
        var objE = document.createElement("div");
        //去除头尾空格，防止空格成为节点
        htmlText =
          htmlText == null ? "" : htmlText.replace(/(^\s*)|(\s*$)/g, "");
        objE.innerHTML = htmlText;
        return objE.childNodes[0];
      }
    </script>

    <style>
      body {
        position: absolute;
        width: 100%;
        height: 100%;
        margin: 0;
        display: flex;
      }
      .mainPanel {
        display: flex;
        flex-direction: column;
        flex-wrap: wrap;
        margin-left: 30px;
        margin-right: 10px;
        margin-top: 20px;
        margin-bottom: 20px;
      }
      .itemPanel {
        width: 300px;
        min-height: 80px;
        margin: 12px;
        padding: 10px;
        border: 1px solid #ddd;
        border-radius: 6px;
        display: flex;
        flex-direction: column;
      }
      .panTitle {
        text-align: center;
        font-size: 18px;
        margin: 0;
        color: #551a88;
      }
      .subTitle {
        font-size: 14px;
        margin: 8px 10px 8px 0px;
        color: gray;
      }
      .link {
        text-decoration: none;
        margin: 8px 10px 8px 15px;
        font-size: 16px;
      }
    </style>
  </body>
</html>
